﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace chesslibrary.cs
{
    public abstract class pieces_chess
    {
        private int moves=0;
		private color_pieces owner;
		public enum Kind {pieces_king,pieces_queen,pieces_rook,pieces_bishop, pieces_knight,pieces_pawn};
        protected pieces_chess(color_pieces owner)
		{
			this.owner=owner;
		}
		public bool IsOwnedBy(color_pieces side)
		{
			return (side==owner);
		}
		public bool IsEnemyOf(color_pieces side)
		{
			return !IsOwnedBy(side);
		}
		public bool IsEnemyOf(pieces_chess piece)
		{
			return !(owner==piece.Owner);	
		}
		public int Moves
		{
			get{return moves;}
		}
        public color_pieces Owner
		{
			get{return owner;}
		}
		public bool HasMoved()
		{
			return (moves>0);
		}
        internal void Move()
		{
			moves++;
		}
		internal void UndoMove()
		{
            if (--moves < 0)
                // Logger.Assert("Undo move called on piece that has not moved yet");
                throw new ChessException("Undo move called on piece that has not moved yet");
		}
		public abstract Kind Type
		{
			get;
		}
    }
}
